import*as e from"../../../core/common/common.js";import*as n from"../../../models/extensions/extensions.js";let i=null;class t extends e.ObjectWrapper.ObjectWrapper{static instance(){return i||(i=new t),i}#e=new Map;constructor(){super(),this.attach()}attach(){const e=n.RecorderPluginManager.RecorderPluginManager.instance();e.addEventListener(n.RecorderPluginManager.Events.PluginAdded,this.#n),e.addEventListener(n.RecorderPluginManager.Events.PluginRemoved,this.#n),e.addEventListener(n.RecorderPluginManager.Events.ViewRegistered,this.#i);for(const n of e.views())this.#i({data:n})}detach(){const e=n.RecorderPluginManager.RecorderPluginManager.instance();e.removeEventListener(n.RecorderPluginManager.Events.PluginAdded,this.#n),e.removeEventListener(n.RecorderPluginManager.Events.PluginRemoved,this.#n),e.removeEventListener(n.RecorderPluginManager.Events.ViewRegistered,this.#i),this.#e.clear()}extensions(){return n.RecorderPluginManager.RecorderPluginManager.instance().plugins()}getView(e){const n=this.#e.get(e);if(!n)throw new Error("View not found");return n}#n=()=>{this.dispatchEventToListeners(r.ExtensionsUpdated,this.extensions())};#i=e=>{const n=e.data;this.#e.has(n.id)||this.#e.set(n.id,new s(n))}}class s{#t;#s;#r=!1;#a=!1;constructor(e){this.#t=e,this.#s=document.createElement("iframe"),this.#s.src=e.pagePath,this.#s.onload=this.#o}#o=()=>{this.#a=!0,this.#r&&this.#t.onShown()};show(){this.#r||(this.#r=!0,this.#a&&this.#t.onShown())}hide(){this.#r&&(this.#r=!1,this.#a=!1,this.#t.onHidden())}frame(){return this.#s}}var r;!function(e){e.ExtensionsUpdated="extensionsUpdated"}(r||(r={}));var a=Object.freeze({__proto__:null,ExtensionManager:t,get Events(){return r}});export{a as ExtensionManager};
